home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / facilis.zip / FACILIS.IM < prev    next >
Text File  |  1985-03-05  |  17KB  |  405 lines

  1.                     Facilis Implementation Manual
  2.  
  3. Version 0.20                                              File: FACILIS.IM
  4.                                                           Updated: 15 Feb 85
  5.  
  6.  
  7.  
  8. INTRODUCTION
  9.  
  10.    Facilis is implemented in Turbo Pascal, an excellent commercial compiler
  11. sold by Borland International.  You must have Turbo to compile the Facilis
  12. source files; it is not capable of compiling itself.
  13.    The source code is contained in three files:
  14.                FACILIS.PAS  -  main program
  15.                BLOCK.PAS    -  an include file
  16.                INTERPRT.PAS -  an include file
  17.    The implementation exploits certain non-standard features of Turbo, such
  18. as the MEM array, and utilizes the segment:offset addressing of the 8088.
  19. Modifications may be required to compile under a different Pascal compiler
  20. or for a different processor.  Also, version 0.20 has been modifed with
  21. an assembly level jump table to speed up run time execution.
  22.    This implementation was done on an IBMPC running the PC-DOS version of
  23. Turbo.  However, it makes no explicit calls to DOS, and should compile
  24. under the CP/M-86 version of Turbo with little or no change.
  25.  
  26.  
  27.  
  28. COMPILING THE COMPILER
  29.  
  30.    The source files may be placed on any drive(s).  A RAM drive is recommended
  31. to save wear on your disks.  Turbo expects to find BLOCK.PAS and INTERPRT.PAS
  32. on the logged drive.  To override this assumption, you can place explicit drive
  33. specifiers in the {$I include directives within FACILIS.PAS.
  34.    Run Turbo.  From the main menu, enter FACILIS.PAS as the Main file.
  35. Go to the Options menu and choose the Com option.  (Because it uses overlays,
  36. Facilis cannot be compiled in memory.)  Quit to the main menu and Compile.
  37.    Compilation results in two files: FACILIS.COM and an overlay file,
  38. FACILIS.000.  These files will be written to the drive that FACILIS.PAS is
  39. loaded from, not necessarily the logged drive.  These are big files.  Allow
  40. enough space or you will get an error writing to disk, aborting compilation.
  41.  
  42.  
  43.  
  44.  
  45. SYNTAX DIAGRAMS
  46.  
  47. (All words in caps are required key words)
  48.  
  49.  
  50. program
  51.                               +----------->----------------------+
  52.                               |                                  |
  53. ---> PROGRAM ---> identifier -+-> ( ---> identifier list ---> ) -+-> ; ---+
  54.                                                                           |
  55.           +-------------------------------------------------------------<-+
  56.           |
  57.           +--> block ------> .
  58.  
  59.  
  60. block
  61.  
  62. --+---> CONST ---+---> identifier --------> = ---> constant ---> ; ---+
  63.   |              ^                                                    |
  64.   +-<------------+--------------------------------------------------<-+
  65.   |
  66.   +---> TYPE ----+---> identifier --------> = ---> type -------> ; ---+
  67.   |              ^                                                    |
  68.   +-<------------+--------------------------------------------------<-+
  69.   |
  70.   +---> VAR ---------> identifier list ---> : ---> type -------> ; ---+
  71.   |                                                                   |
  72.   +-<---------------------------------------------------------------<-+
  73.   |
  74.   v
  75.   |
  76.   +-+-> PROCEDURE ---> identifier --------> formal parameter list  ---+
  77.   | ^                                                                 |
  78.   v |                                                                 |
  79.   +-+-<----------- ; <------- block <---------- ; <-------------------+
  80.   |                                                                   |
  81.   +---> FUNCTION ----> identifier ----> formal parameter list ---+    ^
  82.   |                                                              |    |
  83.   |       +-<----------------------------------------------------+    |
  84.   |       |                                                           |
  85.   |       +---> : ----------> type identifier ---------------------->-+
  86.   |
  87.   +---> BEGIN -------> statement sequence -----> END ----->
  88.  
  89.  
  90. type
  91.  
  92. --+-----------------------> type identifier --------------------------------+->
  93.   |                                                                         |
  94.   +--> ARRAY --> [ -+> constant --> .. --> constant -+> ] --> OF --> type --+
  95.   |                 |                                |                      |
  96.   |                 +--------------  , <-------------+                      |
  97.   |                                                                         |
  98.   |              +->-------------------------------------->-+               |
  99.   |              |                                          |               |
  100.   +--> RECORD ---+-+-> identifier list ---> : ---> type -+--+-> END ------>-+
  101.                    |                                     |
  102.                    +----------------------- ; <----------+
  103.  
  104.  
  105. formal parameter list
  106.  
  107.   +->--------------------------------------------------------------------->-+
  108.   |                                                                         |
  109. --+-> ( -+-+->-------+--> identifier list --> : --> type identifier -+-> ) -+->
  110.          | |         |                                               |
  111.          | +-> VAR --+                                               |
  112.          |                                                           |
  113.          +-<--------------------------------- ; <--------------------+
  114.  
  115.  
  116. identifier list
  117.  
  118. -----------------+--->  identifier  ----+---------------------------->------->
  119.                  |                      |
  120.                  +--------- , <---------+
  121.  
  122.  
  123. identifier
  124.  
  125. -----------------> letter -----+--->-----------+--------------------->------->
  126.                                ^               |
  127.                                +--- letter <---+
  128.                                |               |
  129.                                +--- digit  <---+
  130.                                |               |
  131.                                +----  _  <-----+
  132.  
  133.  
  134. statement sequence
  135.  
  136. -----------------+--->  statement   ----+---------------------------->------->
  137.                  ^                      |
  138.                  +--------- ; <---------+
  139.  
  140.  
  141. statement
  142.  
  143. --+--+-> variable -------------+--> := ---------> expression ------------->-+->
  144.   |  |                         |                                            |
  145.   |  +-> function identifier --+                                            |
  146.   |                                                                         |
  147.   +----> procedure identifier ----+---> actual parameter list ---+-------->-+
  148.   |                               |                              |          |
  149.   |                               +--->--------------------------+          |
  150.   |                                                                         |
  151.   +----> BEGIN ------> statement sequence ------> END -------------------->-+
  152.   |                                                                         |
  153.   |                                              +->---------------------->-|
  154.   |                                              |                          |
  155.   +--> IF --> expression --> THEN --> statement -+-> ELSE --> statement -->-+
  156.   |                                                                         |
  157.   |                            +--->-------------------------------+        |
  158.   |                            |                                   |        |
  159.   +-> CASE -> expression -> OF +-+-> constant +-> : -> statement +-+-> END -+
  160.   |                              |            |                  |          |
  161.   |                              +----- , <---+                  |          |
  162.   |                              |                               |          |
  163.   |                              +--------------- ; <------------+          |
  164.   |                                                                         |
  165.   +----> WHILE ----> expression ------> DO ------> statement ------------->-+
  166.   |                                                                         |
  167.   +----> REPEAT ---> statement sequence ---> UNTIL ---> expression ------->-+
  168.   |                                                                         |
  169.   +----> FOR ------> variable identifier ---> := ---> expression --+        |
  170.   |                                                                |        |
  171.   |    +----<----------------------------------------------------<-+        |
  172.   |    |                                                                    |
  173.   |    +--+-> TO -------+--> expression ---> DO ---> statement ----------->-+
  174.   |       |             |                                                   |
  175.   |       +-> DOWNTO ---+                                                   |
  176.   |                                                                         |
  177.   +---->------------------------------------------------------------------>-+
  178.  
  179.  
  180. expression
  181.  
  182. ---> simple expression --+---+---+---+---+---+------------------------->-+-->
  183.                          |   |   |   |   |   |                           |
  184.                          v   v   v   v   v   v                           |
  185.                          =   <>  <   >   >=  <=                          |
  186.                          |   |   |   |   |   |                           |
  187.                          +---+---+---+---+---+--> simple expression --->-+
  188.  
  189.  
  190. simple expression
  191.  
  192. ---+-->-----+--> term ----+--->-----------------+----+----+---------->------>
  193.    |        |             |                     |    |    |
  194.    +--> + --+             |                     v    v    v
  195.    |        |             |                     +    -    OR
  196.    +--> - --+             |                     |    |    |
  197.                           +---- term <----------+----+----+
  198.  
  199.  
  200. term
  201.  
  202. ------> factor -----------+--->------------+----+----+----+----+----->------>
  203.                           |                |    |    |    |    |
  204.                           |                v    v    v    v    v
  205.                           |                *    /   DIV  MOD  AND
  206.                           |                |    |    |    |    |
  207.                           +--- factor <----+----+----+----+----+
  208.  
  209.  
  210. factor
  211.  
  212. ---+--> unsigned constant --------------------------------------------->-+-->
  213.    |                                                                     |
  214.    +--> variable ------------------------------------------------------>-+
  215.    |                                                                     |
  216.    +--> function identifier ------> actual parameter list ------------->-+
  217.    |                                                                     |
  218.    +--> ( -------> expression ----> ) --------------------------------->-+
  219.    |                                                                     |
  220.    +--> NOT -----> factor --------------------------------------------->-+
  221.  
  222.  
  223. actual parameter list
  224.  
  225. ------> ( ------+---> expression ---+------> ) ---------------------->------>
  226.                 |                   |
  227.                 +-------- , <-------+
  228.  
  229.  
  230. variable
  231.  
  232. ----> variable identifier ---+----+--->------------------------------>------->
  233.                              |    |
  234.                              |    +---> [ --+--> expression --+--> ] --+
  235.                              ^    |         |                 |        |
  236.                              |    |         +------- , <------+        |
  237.                              |    |                                    |
  238.                              |    +---> . -----> field identifier -->--+
  239.                              |                                         |
  240.                              +---<----------------------------------<--+
  241.  
  242.  
  243. constant
  244.  
  245. ---+---+-->-----+-----+---> unsigned number ---------------->-+------>------>
  246.    |   |        |     |                                       |
  247.    |   +--> + --+     |                                       |
  248.    |   |        |     +---> constant identifier ------------>-+
  249.    |   +--> - --+                                             |
  250.    |                                                          |
  251.    +----------------------> literal string ----------------->-+
  252.  
  253.  
  254. unsigned constant
  255.  
  256. ---+------> constant identifier ---------------------------->-+------>------>
  257.    |                                                          |
  258.    +------> unsigned number -------------------------------->-+
  259.    |                                                          |
  260.    +------> literal string --------------------------------->-+
  261.  
  262.  
  263. literal string
  264.  
  265. -------> ' -----+----------->----------+-----> ' ------------>-------------->
  266.                 |                      |
  267.                 +-----> character -----+
  268.                 |                      |
  269.                 +-----------<----------+
  270.  
  271.  
  272. unsigned number
  273.  
  274. ---> unsigned integer ---+--->----------------------------------+->-+------->
  275.                          |                                      |   |
  276.                          +---> . ----> unsigned integer --+--->-+   |
  277.                          |                                |         |
  278.                          v                                |         |
  279.                          +---<-------------------------<--+         |
  280.                          |                                          |
  281.                          +---> E --+-->-----+-> unsigned integer ->-+
  282.                                    |        |
  283.                                    +--> + --+
  284.                                    |        |
  285.                                    +--> - --+
  286.  
  287. unsigned number
  288.  
  289. ------------------------+-----> digit -----+------------------------->------>
  290.                         |                  |
  291.                         +-----<------------+
  292.  
  293.  
  294.  
  295. RESERVED WORDS
  296.  
  297. The following symbols are reserved and cannot be used as identifiers:
  298.  
  299.     AND         DOWNTO      IF          OR          THEN
  300.     ARRAY       ELSE        IN          PACKED      TO
  301.     BEGIN       END         LABEL       PROCEDURE   TYPE
  302.     CASE        FILE        MOD         PROGRAM     UNTIL
  303.     CONST       FOR         NIL         RECORD      VAR
  304.     DIV         FUNCTION    NOT         REPEAT      WHILE
  305.     DO          GOTO        OF          SET         WITH
  306.  
  307.  
  308.  
  309. OPERATION CODES
  310.  
  311. These are shown in the list file when the T option is selected.
  312. Operations take zero, one, or two operands: x represents an 8-bit operand,
  313. usually a level number; y represents a 16-bit quantity, such as an address
  314. or an integer.
  315.  
  316. Code          Action
  317.   0  x  y  Load address
  318.   1  x  y  Load value
  319.   2  x  y  Load indirect
  320.   3  x  y  Update DISPLAY
  321.   4          not used
  322.   5          not used
  323.   6          not used
  324.   7     y  Concatenate
  325.   8     y  Standard functions
  326.   9     y  Add y to the element on top of the stack
  327.  10     y  Jump to y (unconditional)
  328.  11     y  Jump to y if stack top false
  329.  12     y  Jump to y (case table) and select entry
  330.  13     y  Entry in case table ... NOT EXECUTABLE
  331.  14     y  For loop entry test - UP
  332.  15     y  For loop retry test - UP
  333.  16     y  For loop entry test - DOWN
  334.  17     y  For loop retry test - DOWN
  335.  18     y  Mark stack
  336.  19     y  Call user procedure
  337.  20     y  Indexed fetch (element size > 1)
  338.  21     y  Indexed fetch
  339.  22     y  Load block
  340.  23     y  Copy block
  341.  24     y  Load literal
  342.  25     y  Load real
  343.  26     y  Float
  344.  27     y  Read (y denotes type .. 1 integer, 2 real, 4 char)
  345.  28     y  Write string
  346.  29     y  Write - default field widths
  347.  30     y  Write - defined field widths
  348.  31     y  Assign string (of length 1) to char
  349.  32     y  Relation operators for strings
  350.  
  351.  33-130      not used
  352.  
  353. 131        Halt
  354. 132        Exit procedure
  355. 133        Exit function
  356. 134        Fetch
  357. 135        Not
  358. 136        - integer (unary)
  359. 137        Write real - defined field
  360. 138        Store
  361. 139        Real =
  362. 140        Real <>
  363. 141        Real <
  364. 142        Real <=
  365. 143        Real >
  366. 144        Real >=
  367. 145        Integer =
  368. 146        Integer <>
  369. 147        Integer <
  370. 148        Integer <=
  371. 149        Integer >
  372. 150        Integer >=
  373. 151        Or
  374. 152        + integer
  375. 153        - integer
  376. 154        + real
  377. 155        - real
  378. 156        And
  379. 157        * integer
  380. 158        Div
  381. 159        Mod
  382. 160        * real
  383. 161        /
  384. 162        Readln
  385. 163        Writeln
  386. 164        - real (unary)
  387. 165        Index string
  388. 166        Assign string temporary to string
  389. 167        Convert array to string
  390. 168        Assign character to string
  391. 169        Assign string to string
  392. 170        Write string
  393. 171        Write string temporary
  394. 172        Value parameter - string
  395. 173        Value parameter - string temporary
  396. 174        Convert string to array
  397. 175        Convert string temporary to array
  398. 176        Write string - defined field
  399. 177        Write string temporary - defined field
  400.  
  401. 178-255     not used
  402.  
  403.  
  404. array
  405. 176        Write string - defi